<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="global.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>交付物明细管理</title>
<style type="text/css">
.ctl{
	text-decoration: none;
	color: blue;
	margin: auto 7px;
}
.ctl:HOVER{
	text-decoration: underline;
}
.center{
	text-align: center;
}
</style>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="交付物明细管理"
			data-options="
				rownumbers:true,
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20
			">
		<thead>
			<tr>				
				<th data-options="field:'productSequenceNo',width:80,align:'center'">产品序列号</th>
				<th data-options="field:'eTag',width:80,align:'center'">电子标识号</th>
				<th data-options="field:'remark',width:270,align:'center'">描述</th>
				<th data-options="field:'id',width:130,align:'center',formatter:formatControl">管理</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		<div>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="clearForm('form', 'addProjectDeliveryDetail')">新增</a>
		</div>
		<div>			
			产品序列号: <input class="easyui-textbox" type="text" id="productSequenceNo" style="width:200px;height:25px;">
			电子标识号: <input class="easyui-textbox" type="text" id="eTag" style="width:200px;height:25px;">
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
		</div>
	</div>
	
	<div id="addProjectDeliveryDetail" class="easyui-window" title="新增交付物明细" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:600px; height:250px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="form" method="post" action="editProjectDeliveryDetail" style = "width:100%; height: 100%">
					<table width="100%" height="100%">
						<tr>
							<td width="100px;" align="right">产品序列号：</td>
							<td>
								<input class="easyui-textbox" name="productSequenceNo" id="eddProductSequenceNo" data-options="required:true" style="width: 150px;" />
							</td>
							<td width="100px;" align="right">电子标识号：</td>
							<td>
								<input class="easyui-textbox" name="eTag" data-options="required:true" style="width: 150px;" />
							</td>
						</tr>
						<tr>
							<td align="right">描述：</td>
							<td colspan="3">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 420px; height: 80px;" name="remark">
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="$('#form').submit()" style="width:80px">确 定</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#addProjectDeliveryDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		function formatControl(val, row){
			return '<a class="ctl" href="javascript:void(0)" onclick="lookDetail(' + val + ')">查看</a>'+
			' <a class="ctl" href="javascript:void(0)" onclick="editProjectDeliveryDetail(' + val + ')">编辑</a>'+
			' <a class="ctl" href="javascript:void(0)" onclick="delProjectDeliveryDetail(' + val + ')">删除</a>';
		}
		function search(){
			var dg = $("#dg");
			var productSequenceNo = $("#productSequenceNo").textbox("getValue").trim();
			var eTag = $("#eTag").textbox("getValue").trim();
			var url = "queryProjectDeliveryDetail?productSequenceNo=" + productSequenceNo + "&eTag=" + eTag;
			dg.datagrid('reload', url);
		}
		function lookDetail(id){
			var params = "id=" + id;
			$.ajax({
				  type: "GET",
				  url: "findProjectDeliveryDetail",
				  data: params,
				  success:function(data){
					  	var val = $.parseJSON(data);
						if(val.success){
							var item = val.data;
							
							$("#lookProductSequenceNo").textbox("setValue", item.productSequenceNo);
							$("#lookETag").textbox("setValue", item.eTag);
							$("#lookRemark").textbox("setValue", item.remark);
							
							$('#lookDetail').window('open');
						}else{
							$.messager.alert("提示", val.msg, "error");
						}
				  }
			});
		}
		function editProjectDeliveryDetail(id){
			var params = "id=" + id;
			$.ajax({
				  type: "GET",
				  url: "findProjectDeliveryDetail",
				  data: params,
				  success:function(data){
					  	var val = $.parseJSON(data);
						if(val.success){
							var item = val.data;

							$("#editId").val(id);
							$("#editProductSequenceNo").textbox("setValue", item.productSequenceNo);
							$("#editETag").textbox("setValue", item.eTag);
							$("#editRemark").textbox("setValue", item.remark);
							
							$('#editProjectDeliveryDetail').window('open');
						}else{
							$.messager.alert("提示", val.msg, "error");
						}
				  }
			});
		}
		function delProjectDeliveryDetail(id){
			$.messager.confirm("删除确认", "您确定要删除所选的交付物明细吗？", function(r){
				if(r){
					params = "id=" + id;
					$.ajax({
					  type: "GET",
					  url: "delProjectDeliveryDetail",
					  data: params,
					  success:function(data){
						  	var val = $.parseJSON(data);
							if(val.success){
								bottomRight('提示', '操作成功！');
								$('#dg').datagrid('reload');
							}else{
								$.messager.alert("提示", val.msg, "error");
							}
					  }
					});
				}
			});
		}
		$(function(){
			$("#form").form({
				onSubmit: function(){
					var isValid = $(this).form('validate');
					return isValid;	// 返回false将停止form提交 
			    },
				success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						bottomRight('提示', '操作成功！');
						$('#dg').datagrid('reload');
						$('#addProjectDeliveryDetail').window('close');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
				}
			});
			$("#editForm").form({
				onSubmit: function(){
					var isValid = $(this).form('validate');
					return isValid;	// 返回false将停止form提交 
			    },
				success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						bottomRight('提示', '操作成功！');
						$('#dg').datagrid('reload');
						$('#editProjectDeliveryDetail').window('close');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
				}
			});

			search();
		});
	</script>
	<div id="lookDetail" class="easyui-window" title="交付物明细详情" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:600px; height:250px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<table width="100%" height="100%">
					<tr>
						<td width="100px;" align="right">产品序列号：</td>
						<td>
							<input class="easyui-textbox" id="lookProductSequenceNo" readonly="readonly" data-options="required:true" style="width: 150px;" />
						</td>
						<td width="100px;" align="right">电子标识号：</td>
						<td>
							<input class="easyui-textbox" id="lookETag" readonly="readonly" data-options="required:true" style="width: 150px;" />
						</td>
					</tr>
					<tr>
						<td align="right">描述：</td>
						<td colspan="3">
							<input class="easyui-textbox" data-options="multiline:true" style="width: 420px; height: 80px;" id="lookRemark">
						</td>
					</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:$('#lookDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<div id="editProjectDeliveryDetail" class="easyui-window" title="编辑交付物明细" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:600px; height:250px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<form id="editForm" method="post" action="editProjectDeliveryDetail" style = "width:100%; height: 100%">
					<input type="hidden" id="editId" name = "id">
					
					<table width="100%" height="100%">
						<tr>
							<td width="100px;" align="right">产品序列号：</td>
							<td>
								<input class="easyui-textbox" name="productSequenceNo" id="editProductSequenceNo" data-options="required:true" style="width: 150px;" />
							</td>
							<td width="100px;" align="right">电子标识号：</td>
							<td>
								<input class="easyui-textbox" name="eTag" id="editETag" data-options="required:true" style="width: 150px;" />
							</td>
						</tr>
						<tr>
							<td align="right">描述：</td>
							<td colspan="3">
								<input class="easyui-textbox" data-options="multiline:true" style="width: 420px; height: 80px;" name="remark" id="editRemark" />
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="$('#editForm').submit()" style="width:80px">确 定</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#editProjectDeliveryDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>

</body>
</html>